<form action="/admini/manageuser/address/" method="get" style="margin:0px">
<div style=" border:1px solid #DDDDDD; padding:2px; margin:2px;">
<label for="quick">快速搜索：</label><input type="text" id="quick" name="quick" value="<?php echo $this->quick;?>" />
<input type="submit" id="queryButton" value="查询"/>
</div>
</form>

<div class="dataTable">
        <table>     
            <tfoot>
                <tr><td colspan="14"><input class="button" id="edit-button" type="button" value="编辑" /><input class="button" id="del-button" type="button" value="删除" /></td></tr>
            </tfoot>
            <tr>
                <th class="w0" width="2%">&nbsp;</th>
                <th class="w1" width="5%">ID</th>
                <th class="w2" width="5%">用户名</th>
                <th class="w3" width="5%">仓库号</th>
                <th class="w4" width="10%">国家</th>
                <th class="w7" width="23%">街道</th>
                <th class="w8" width="10%">收件人</th>
                <th class="w9" width="10%">手机</th>
                <th class="w10" width="10%">电话号码</th>
                <th class="w10" width="5%">邮编</th>
                <th class="w10" width="5%">城市</th>
                <th class="w10" width="5%">省/州或地区</th>
                <th class="w10" width="5%">EORI号码</th>
            </tr>  
        
            <?php if($this->AddressList){
                foreach ($this->AddressList as $Item) {?>
                    <tr>
                        <td class="w0" nowrap align="center"><input type="checkbox" id="checkbox" name="checkbox" value="<?php echo $Item->id;?>" /></td>
                        <td class="w1" nowrap align="center"><?php echo $Item->id;?></td>
                        <td class="w2" nowrap align="center"><?php echo $Item->userinfo==null?"用户被删除":htmlspecialchars($Item->userinfo->nikename);?></td>
                        <td class="w3" nowrap align="center"><?php echo $Item->userinfo==null?"用户被删除":htmlspecialchars($Item->userinfo->storeno);?></td>
                        <td class="w4" nowrap align="center"><?php echo htmlspecialchars($Item->StateName->name);?></td>
                        <td class="w7"><?php echo htmlspecialchars($Item->street);?></td>
                        <td class="w8" nowrap align="center"><?php echo htmlspecialchars($Item->linkMan);?></td>
                        <td class="w9" nowrap align="center"><?php echo htmlspecialchars($Item->mobile);?></td>
                        <td class="w10" nowrap align="center"><?php echo htmlspecialchars($Item->phone);?></td>
                        <td class="w10" nowrap align="center"><?php echo htmlspecialchars($Item->postcode);?></td>
                        <td class="w10" nowrap align="center"><?php echo htmlspecialchars($Item->city_name);?></td>
                        <td class="w10" nowrap align="center"><?php echo htmlspecialchars($Item->province_name);?></td>
                        <td class="w10" nowrap align="center"><?php echo htmlspecialchars($Item->eori);?></td>
                    </tr>
            <?php  } }?>
        </table>
    </div>                
    <div class="toolbar" <?php if (empty($this->AddressList)) echo "style='display: none'"; ?>>
        <?php echo $this->partial('paging.phtml', array("pages" => $this->Address,"pamas"=>"quick=".$this->quick)); ?>
    </div>

<script language="javascript">
    $('#del-button').click(function(){
         var idlist = '';
         $('input[name="checkbox"]:checked').each(function(){   
                var id = $(this).attr("value");
                id=id.replace(/[^\d]*/ig,"");
		idlist+= id+',';
	});
        if(idlist == ''){
            alert("请选择地址");
            return false;
        }else{
            if(confirm("您确定删除该收件人地址？","提示信息")){ 
                $.ajax({
                    type: 'POST',
                    url: '/admini/manageuser/deladdress/idlist/'+idlist,
                    success: function(data) {
                        if(data == 1){
                            alert("删除成功");
                        }else{
                            alert("发生未知错误，请重新操作");
                        }
                        location.href='/admini/manageuser/address/';
                    }
                });
            }
        }
    });
    $('#edit-button').click(function(){
        var id = getbillid();
        if(id == ''){
            alert("请选择用户");
            return false;
        }else{
           location.href='/admini/manageuser/editaddress/id/'+id;
        }
    });
    function getbillid()
    {
         var id = '';
         $('input[name="checkbox"]:checked').each(function(){    
		id = $(this).val();
                return false;
	});
        return id;
    }
</script>